Hi guys, |
Re: Filter compoud with DXL I don't deal with 'Filters', but it seems to me something like this should work:
Get the Filters and Operators from the user via GUI, store them in an Array or two.
Filter fInArray = null, fCompound = null
string Operator
bool Done = false
while(!Done)
{ if (array is empty) then break
fInArray = next filter in the stored Array
Operator = operator associated with this Filter, also I suppose in the Array
if (Operator == "Or")
fCompound = fCompound or fInArray
elseif(Operator == "And")
fCompound = fCompound and fInArray
else fCompound = fCompound ! fInArray // not sure what this means, perhaps its 'and !'.
print "InLoop, InArray>Compound = " (stringOf(mod, fInArray)) "\t>" (stringOf(mod, fCompound)) "\n"
}
print "Compound = >" (stringOf(mod, fCompound)) "\n"
|
Re: Filter compoud with DXL llandale - Wed Apr 08 13:58:33 EDT 2009 I don't deal with 'Filters', but it seems to me something like this should work:
Get the Filters and Operators from the user via GUI, store them in an Array or two.
Filter fInArray = null, fCompound = null
string Operator
bool Done = false
while(!Done)
{ if (array is empty) then break
fInArray = next filter in the stored Array
Operator = operator associated with this Filter, also I suppose in the Array
if (Operator == "Or")
fCompound = fCompound or fInArray
elseif(Operator == "And")
fCompound = fCompound and fInArray
else fCompound = fCompound ! fInArray // not sure what this means, perhaps its 'and !'.
print "InLoop, InArray>Compound = " (stringOf(mod, fInArray)) "\t>" (stringOf(mod, fCompound)) "\n"
}
print "Compound = >" (stringOf(mod, fCompound)) "\n"
Thanks for input. I've checked it. But unfortunatelly it doesn't work as assumed. The final results is that every call of assigment fComoud is embedded in fInArray in the same way i've posted in my previous mail... I think there must be another way... |
Re: Filter compoud with DXL SystemAdmin - Thu Apr 09 07:26:39 EDT 2009 First of all, I'll explain my thinking of this... Each filter is done one at a time, so order is important. <Module Name>,<Attribute Name>,<Value>,<Compare Type>,<Accept?>,<Combination> The first four probably make since. Accept? is basically a inverse not (Inverts result when false) and Combination is how the previous filter is combined (ANDed or ORed) with the next. This value is arbitrary if just one filter is applied. More types can be added in very easily by just defining them. I store all these values in multiple skip lists that all have the same key to keep them in line. here is the main part... for obj in mod do { abs = obj."Absolute Number" re_fil = find(filterList,abs,prev) // Assigns filter_o if more than one filter if(attrT"" == "STRING") // Test defined type filter_o = (obj.attrN"" == attrV"") else if(attrT"" == "INT<"") < (intOf attrV"")) else if(attrT"" == "INT>") filter_o = ((intOf obj.attrN"") > (intOf attrV"")) else if(attrT"" == "INT=") filter_o = ((intOf obj.attrN"") == (intOf attrV"")) else if(attrT"" == "DATE>") { d1 = obj.attrN"" d2 = attrV"" filter_o = (intOf d1 > intOf d2) } else if(attrT"" == "DATE<"" d2 = attrV"" filter_o = (intOf d1 < intOf d2) } else if(attrT"" == "DATE=") { d1 = obj.attrN d2 = date attrV"" filter_o = (intOf d1 == intOf d2) } else if(attrT"" == "TEXT") filter_o = (matches(attrV"",obj.attrN"")) else if(attrT"" == "ENUMERATION") filter_o = (isMember(obj.attrN,attrV"")) else filter_o = true if(!acc_rej) filter_o = !filter_o if(filterType"" == "AND") { prev = true re_fil = find(filterList,abs,prev) // Assigns filter_o if more than one filter filter_o = filter_o && prev } else if(filterType"" == "OR") { prev = false re_fil = find(filterList,abs,prev) // Assigns filter_o if more than one filter filter_o = filter_o || prev } if(re_fil) // deletes old value if it exists delete(filterList,abs) put(filterList,abs,filter_o) } // end for obj in mod loop Then after the filter skip list is filled... for filter_o in filterList do { abs = (int key filterList) if(filter_o) { acc++ accept (object abs) } else { rej++ reject (object abs) } } print m."Name"" Filtering - \tAccepted: "acc"\tRejected: "rej"\n" delete filterList filtering on You should be able to do any logical combination with this (though it may not be the shortest one) |